<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title>用户管理</title>
<%@ include file="/WEB-INF/views/include/JsCss.jsp"%>
	
<script type="text/javascript" charset="utf-8">
var webRoot="${webRoot}";

	var dataGrid;
	$(function(){
		 dataGrid=$("#dataGrid").dcDataGrid({
			url:'${webRoot}/sys/user/querySysUser.json',
			frozenColumns:[[
		                {checkbox:true,field:'id',width:$(this).width() * 0.1}
					]],
			columns:[[
						{field:'userCode',title:'座席编号',width:$(this).width() * 0.1,sortable:true},
						{field:'userName',title:'座席名字',width:$(this).width() * 0.1,sortable:true},
						{field:"hobby.code",title:"爱好",sortable:true},
						{field:"useStatus.name",title:"状态",sortable:false},
						{field:'opt',title:'操作',width:$(this).width() * 0.1,rowspan:1,align:'center',formatter:function(value,row,index){
							
							var html="";
							 	html ='<input type="button" class="edit" 		data-id="'+row.id+'"  value="修改"/>';
								html+='<input type="button" class="detail" 		data-id="'+row.id+'" value="详情"/>';
								html+='<input type="button" class="enabled" 	data-id="'+row.id+'" value="启用"/>';
								html+='<input type="button" class="suspend" 	data-id="'+row.id+'" value="暂停"/>';
								html+='<input type="button" class="deActivate"  data-id="'+row.id+'" value="停用"/>';
								html+='<input type="button" class="delete" 		data-id="'+row.id+'" value="删除"/>';
							return html;
						}}
					]],
					
			<shiro:hasPermission name="sys:user:sysUserAdd">
			/**新增 用户*/
			addFunction:function(){
				common.frame("${webRoot}/sys/user/sysUserAdd.htm", "新增用户","660","330");
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserEdit">
			/** 修改 用户*/
			editFunction:function(id){
				common.frame("${webRoot}/sys/user/sysUserEdit.htm?id="+id, '修改用户','660','330');
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserDetail">
			/** 用户 详情*/
			detailFunction:function(id){
				common.frame("${webRoot}/sys/user/sysUserDetail.htm?id="+id,"用户详情","660","230");
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserEnabled">
			/** 启用 用户 */
			enabledFunction:function(id,data){
				dataGrid.confirm("你确定要启用该用户吗？","${webRoot}/sys/user/enabledSysUser.json",{id:id},"启用成功！");
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserSuspend">
			/** 暂停  用户 */		
			suspendFunction:function(id,data){
				dataGrid.confirm("你确定要暂停该用户吗？","${webRoot}/sys/user/suspendSysUser.json",{id:id},"暂停成功！");
				
			},
			suspendFilter:function(data){
				var flag=false;
				if(data.code=="admin"){
					return flag;
				}
				if(data.useStatus&&(data.useStatus.code=="ENABLED")){
					flag=true
				}
				return flag;
			}
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserDeActivate">
			/** 停用  用户 */
			deActivateFunction:function(id,data){
				dataGrid.confirm("你确定要停用该用户吗？","${webRoot}/sys/user/deActivateSysUser.json",{id:id},"停用成功！");
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserDelete">
			/** 删除 单个用户 ***/
			deleteFunction:function(id,data){
				dataGrid.confirm("你确定要删除该用户吗？","${webRoot}/sys/user/deleteSysUser.json",{id:id},"删除成功！");
				
			},
			</shiro:hasPermission>
			
			
			<shiro:hasPermission name="sys:user:sysUserDeleteAll">
			/** 删除 选中用户*/
			deleteAllFunction:function(){
				dataGrid.deleteAll("你确定要删除选中的用户吗?","${webRoot}/sys/user/deleteAllSysUser.json");
				
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserExport">
			/** 导出  用户*/
			exportFunction:function(){
				dataGrid.download(function(param){
					common.send("${webRoot}/sys/user/exportSysUser.json",param,function(data){
						common.download(data);
					});
				});
			},
			</shiro:hasPermission>
			
			<shiro:hasPermission name="sys:user:sysUserImport">
			/**
				上传 用户
			*/
			importFunction:function(){
				var param={}
				 	param["link"]="D:\\myTest\\a.xls";
					param["excel_01_userName"]="用户名称";
					param["excel_02_userCode"]="用户代码";
					param["excel_03_hobby"]="爱好";
					common.send("${webRoot}/sys/user/importSysUser.json",param,function(data){
						dataGrid.refresh();
						dataGrid.closeImportWin();
					})
				/* dataGrid.importExcel(function(param){
					param["link"]="D:\\a.xls"
					common.send("${webRoot}/sys/user/importSysUser.json",param,function(data){
						dataGrid.refresh();
						dataGrid.closeImportWin();
					})
				}) */
			},
			
			exportTemplateFunction:function(param){
				common.send("${webRoot}/sys/user/exportSysUser.json",param,function(data){
					common.download(data);
				});
			},
			</shiro:hasPermission>
			
			//其他
			afterLoadFunction:function(data){
				
			},
			
			/**高级搜索 窗口高度，宽度*/
			advanceSearchWidth:430,
			advanceSearchHeight:200,
			sortName:"id",
			sortOrder:"desc",
			queryParams:{
				"search_EQ_dataStatus":"VALID"
				
				//"search_LK_userCode":"admin"
				//"search_LK_userCode":function(){return $("#userCode").val()}(),
				//"search_OR":function(){return {EQ_dataStatus:"VALID",EQ_userName:"admin1"}}(),
				//"search_OR":{EQ_dataStatus:"VALID",EQ_userName:"admin"},
				
				//"search_OR_EQ_dataStatus|LK_userName":["VALID","admin1"],
				// "search_OR_LK_userCode|LK_userName":"admin",
				/**
				"search_EXISTS_com.dc.modules.sys.user.domain.DcSysUserRole.sysRole":{
					"EQ_id":"admin"
				},
				"search_EXISTS_com.dc.modules.sys.user.domain.DcSysUserRole.sysRole":{
					"EQ_id":function(){return "admin"}()
				}
				*/
				//"search_LK_userCode":"admin"
			}//键值对传递参数
		});
	});
</script>
</head>
<body>
 
 	<!-- 导入 -->
    <div  class="importWin" >
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false" class="datat">
				 <table>
				<tr>
					<th>导入:</th>
					<td>
						<input type="file"  name="file" id="file"  value=""/>
						
						<input type="hidden" name="excel_01_userName"  class="excel" value="用户名">
						<input type="hidden" name="excel_02_userCode"  class="excel" value="登录名">
						<input type="hidden" name="excel_03_hobby"     class="excel" value="爱好">
					</td>
				</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" class="sbmt">
				<a class="easyui-linkbutton importSubmit" data-options="iconCls:'icon-search'">导入</a>
				<a class="easyui-linkbutton exportTemplate" data-options="iconCls:'icon-search'">模板</a>
				<a class="easyui-linkbutton importCancel" data-options="iconCls:'icon-cancel'">关闭</a>
			</div>
		</div>
	</div>
	
	 <!-- 高级搜索界面 -->
	<div  class="advanceSearchWin" >
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false" class="datat">
				 <table>
				<tr>
					<th>登录名:</th>
					<td>
						<input type="text"  name="search_LK_userCode" id="search_LK_userCode"  value="${agent.agentNo}"/>
					</td>
				</tr>
				<tr>
					<th>姓名:</th>
					<td>
						<input type="text"  name="search_LK_userName" id="search_LK_userName"  value="${agent.agentName}"/>
					</td>
					<th>爱好:</th>
					<td>
						<input type="text"  name="search_EQ_hobby" id="search_EQ_hobby"  value="${agent.rgroup.agentGroupName}"/>
					</td>
				</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" class="sbmt">
				<a class="easyui-linkbutton advanceSearch" data-options="iconCls:'icon-search'">搜索</a>
				<a class="easyui-linkbutton advanceCancel" data-options="iconCls:'icon-cancel'">关闭</a>
			</div>
		</div>
	</div>
	
	
	<!-- 工具条 -->
	<div id="toolbar" >  
        <table>  
            <tr>  
                <td style="padding-left:2px;">  
	                <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" id="btnAdvanceSearch">高级搜索</a>
                 	<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="btnAdd" >添加</a>
                 	<a href="#" class="easyui-linkbutton" iconCls="icon-Download" plain="true" id="btnDownload">下载</a>
                	<a href="#" class="easyui-linkbutton" iconCls="icon-Import" plain="true" id="btnImport">导入</a>
                 	<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="btnRemove">删除</a>
                	
                	<div class="dialog-tool-separator"></div>
                </td>  
                <td style="text-align:right;padding-right:2px;width:70%;">  
                     <input class="easyui-searchbox" id="simpleSearch" ></input>		
					<div id="menu">
						<div data-options="name:'OR_LK_userName|LK_userCode',iconCls:'icon-ok'">全部</div>
							<div data-options="name:'LK_userCode'">登录名</div>
							<div data-options="name:'LK_userName'">座席名字</div>
					</div>  
                </td> 
            </tr>  
        </table>  
    </div>
   
   <!-- dataGrid -->
	<table id="dataGrid"></table>
</body>
</html>